<template>
  <div class="main">
    <el-aside width="200px">
      <el-row class="tac">
        <el-col :span="12">
         <el-radio-group v-model="isCollapse" >
           <h5 @click="getType" >|||</h5>
          <!-- <el-radio-button :label="false">展开</el-radio-button>
          <el-radio-button :label="true">收起</el-radio-button> -->
        </el-radio-group>
          <el-menu
           default-active="1-1"
            class="el-menu-vertical"
            background-color="#373d41"
            text-color="#fff"
            active-text-color="#ffd04b"
            padding-left="0px"
            margin="0px"
            :collapse="isCollapse"
            router
             >
            <el-submenu :index="'/'+item.path" v-for="(item,index) in menuList" :key="index">
              <template slot="title">
                <i class="el-icon-user"></i>
                <span>{{item.authName}}</span>
              </template>
              <el-menu-item-group>
                <el-menu-item :index="'/'+list.path" v-for="(list,id) in item.children" :key="id">
                  <i class="el-icon-menu"></i>
                  {{list.authName}}</el-menu-item
                >
              </el-menu-item-group>
            </el-submenu>
          </el-menu>
        </el-col>
      </el-row>
    </el-aside>
  </div>
</template>

<script>
import {getMenu} from "../api/index"
export default {
  name: "",
  data() {
    return {
      menuList:[],
      flag:true,
      isCollapse:false
    };
  },
 created(){
   this.getLeft();
 },
  methods: {
  async  getLeft(){
      let {data,meta:{msg,status}} = await getMenu();
      if(status == 200){
        this.$message({ type: "success", message: msg });
      this.menuList = data;
        // console.log(this.menuList);
      } else {
        this.$message({ type: "info", message: "获取数据失败" });
      }
    },
     getType(){
       if(this.flag){
       this.isCollapse =true;
       this.flag = false;
       }else{
       this.isCollapse = false;
         this.flag = true;
       }
    }
  },
  filters: {},
  watch:{
   
  }
};
</script>

<style scoped lang='css'>
.main{
  height: 100%;
}
/* 左边 */
.el-aside {
  background-color: #373d41;
  color: white;
  text-align: center;
  height: 100%;
}
h5 {
  width: 200px;
  background-color: #4a5064;
  color: #fff;
  font-size: 12px;
  text-align: center;
  line-height: 22px;
  cursor: pointer;
  letter-spacing: 0.12em;
}

.el-menu-vertical {
  border: none;
  width: 200px;
    
}

.el-menu-vertical:not(.el-menu--collapse) {
  min-height: 100%;
}
</style>